import * as Types from './types';

const mutations = {
    // 更改登录状态
    [Types.VAILD_LOGIN](state, data) {
        state.login = data;
    },
    [Types.UPDATE_TICKER](state, data) {
        state.TickerData = data;
        // btc
        state.TickerData.btc.btc = data.btc.last;
        state.TickerData.btc.ltc = data.ltc.last;
        state.TickerData.btc.eth = data.eth.last;
        // ltc
        state.TickerData.ltc.btc = data.btc.last;
        state.TickerData.ltc.ltc = data.ltc.last;
        state.TickerData.ltc.eth = data.eth.last;
        // eth
        state.TickerData.eth.btc = data.btc.last;
        state.TickerData.eth.ltc = data.ltc.last;
        state.TickerData.eth.eth = data.eth.last;
    },
    // 获取比特币
    [Types.UPDATE_BTC](state, data) {
        state.TickerData.btc = data;
    },
    // 获取莱特币
    [Types.UPDATE_LTC](state, data) {
        state.TickerData.ltc = data;
    },
    // 获取以太坊
    [Types.UPDATE_BTC](state, data) {
        state.TickerData.eth = data;
    },
    [Types.SHOWLOADING](state) {
        state.loading = true;
    },
    [Types.HIDELOADING](state) {
        state.loading = false;
    }
}

export default mutations;